<template>
	<view class="waterfall-item" @tap="onTap">
		<image :src="params.head_portrait" mode="widthFix" @load="emitHeight" @error="emitHeight" style="border-radius: 24rpx;" v-if="params.head_portrait"></image>
		<image :src="imgUrl + 'static/web/img/493bbddcd065f92ef0729435dbfdacd.png'" mode="widthFix" @load="emitHeight" @error="emitHeight" style="border-radius: 24rpx;" v-else></image>
		<view class="content">
			<view class="" style="display: flex;align-items: center;justify-content: space-between;">
				<view class="" style="display: flex;align-items: center;">
					<view style="font-size: 32rpx;font-family: PingFang SC;font-weight: 600;color: #000013;" :class="params.is_vip == 1 ? 'onColor' : ''">{{params.real_name}}</view>
					<image style="width: 26rpx;height: 30rpx;margin-left: 10rpx;" :src="imgUrl + 'static/web/icon/icon_renzheng.png'" mode="" v-if="params.is_vip == 1"></image>
				</view>
				<image style="width: 34rpx;height: 34rpx;" :src="imgUrl + 'static/web/icon/icon_xin.png'" mode="" @click.stop="collection" v-if="params.is_collection == 1"></image>
				<image style="width: 34rpx;height: 34rpx;" :src="imgUrl + 'static/web/icon/icon_xins.png'" mode="" @click.stop="collection" v-else></image>
			</view>
			<view class="money">{{ params.age || '' }}岁 · {{ params.height || '' }}cm · {{ params.city || '' }}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"helang-waterfall",
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {
				imgUrl: this.$http.baseUrl, // 服务器域名
			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item').boundingClientRect(data => {
					let height = Math.floor(data.height);
					this.$emit("height",height,this.$props.tag);
				}).exec();
			},
			onTap(){
				this.$emit("click",this.$props.params,this.$props.tag,this.$props.index);
			},
			collection(){
				this.$emit('collection',this.$props.params,this.$props.tag,this.$props.index);
			}
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-item{
	padding: 16rpx;
	background-color: #fff;
	border-radius: 4px;
	font-size: 28rpx;
	color: #666;
	margin-bottom: 20rpx;
	
	image{
		display: block;
		width: 100%;
		// 默认设置一个图片的大约值
		height: 350rpx;
	}
	
	.content{
		margin-top: 20rpx;
		.money{
			font-size: 24rpx;
			font-family: PingFang;
			font-weight: 400;
			color: #6A6A7E;
			margin-top: 10rpx;
		}
		
		.label{
			background-color: #fa3534;
			color: #fff;
			font-size: 20rpx;
			padding: 4rpx 16rpx;
			border-radius: 20rpx;
		}
		
		.shop-name{
			font-size: 20rpx;
			color: #999;
		}
	}
}
.onColor {
	color: #F1A532 !important;
}
</style>
